//
//  SearchCollectionViewCell.m
//  MMLOOK
//
//  Created by dllo on 15/9/7.
//  Copyright (c) 2015年 武俊娥. All rights reserved.
//

#import "SearchCollectionViewCell.h"
#import "AsynConnect.h"
#define SETCOLOR(R,G,B) [UIColor colorWithRed:(CGFloat)R/255 green:(CGFloat)G/255 blue:(CGFloat)B/255 alpha:1.0]
@interface SearchCollectionViewCell ()


@end

@implementation SearchCollectionViewCell

- (void)dealloc
{
        [_likeLable release];
    [_priceLable release];
    [_detailLable release];
    [_likeLable release];
    [_imageView release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatSubView];
        
        
        
    }
    return self;
}

- (void)creatSubView
{
    self.imageView = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, (self.frame.size.height - 30) * OffHeight)] autorelease];
    _imageView.image = [UIImage imageNamed:@"home.jpg"];
    [self.contentView addSubview:_imageView];
    
    self.detailLable = [[[UILabel alloc] initWithFrame:CGRectMake(5 * OffWidth, self.imageView.frame.size.height, (self.frame.size.width - 5) * OffWidth, 17 * OffHeight)] autorelease];
    self.detailLable.font = [UIFont systemFontOfSize:15 * OffHeight];
    self.detailLable.backgroundColor = [UIColor clearColor];
    self.detailLable.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:self.detailLable];
    
    self.priceLable = [[[UILabel alloc] initWithFrame:CGRectMake(0, self.imageView.frame.size.height + 20, self.imageView.frame.size.width / 2, 15 * OffHeight)] autorelease];
    self.priceLable.font = [UIFont systemFontOfSize:13 * OffHeight];
    self.priceLable.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:_priceLable];
    
    self.likeLable = [[[UILabel alloc] initWithFrame:CGRectMake(self.imageView.frame.size.width / 2, self.imageView.frame.size.height + 20, self.imageView.frame.size.width / 2, 15 * OffHeight)] autorelease];
    _likeLable.textAlignment = NSTextAlignmentRight;
    self.likeLable.font = [UIFont systemFontOfSize:13 * OffHeight];
    self.likeLable.textColor = [UIColor lightGrayColor];
    [self.contentView addSubview:_likeLable];
}

- (NSMutableAttributedString *)colorData: (NSString *)withStr
{
    NSMutableAttributedString *dataStr = [[[NSMutableAttributedString alloc] initWithString:withStr] autorelease];
    for (int i = 0; i < withStr.length - self.text.length + 1; i++) {
        if ([[withStr substringWithRange:NSMakeRange(i, self.text.length)] isEqualToString:self.text]) {
            NSRange range = NSMakeRange(i, self.text.length);
            [dataStr addAttribute:NSForegroundColorAttributeName value:SETCOLOR(253, 181, 83) range:NSMakeRange(range.location, range.length)];
        }
    }
    return dataStr;
}






@end
